#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010],sb[200010],sr[200010],ssb,ssr;
int dfs(int x){
	int ans=0;
	if(x>n){
		for(int i=1;i<=ssb;i++){
			if(sb[i]==sb[i-1])ans+=sb[i];
		}
		for(int i=1;i<=ssr;i++){
			if(sr[i]==sr[i-1])ans+=sr[i];
		}
		return ans;
	}
	sb[++ssb]=a[x];
	ans=dfs(x+1);
	ssb--;
	sr[++ssr]=a[x];
	ans=max(ans,dfs(x+1));
	ssr--;
	return ans;
}
int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d",&a[i]);
		printf("%d\n",dfs(1));
	}
	return 0;
}
